package com.sams.listener;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import org.apache.catalina.SessionEvent;
import org.apache.catalina.SessionListener;

public class ListenerCount implements HttpSessionListener{

	static int count;
	public void sessionCreated(HttpSessionEvent arg0) {
		count++;
		HttpSession session=arg0.getSession();
		ServletContext sctx=session.getServletContext();
		sctx.setAttribute("count", count);
		
	}

	public void sessionDestroyed(HttpSessionEvent arg0) {
		if(count>0) {
			count--;
			HttpSession session=arg0.getSession();
			ServletContext sctx=session.getServletContext();
			sctx.setAttribute("count", count);
		}
		
	}

	 
}
